home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_08_05 / 8n05126b < prev    next >
Text File  |  1990-04-17  |  1KB  |  40 lines

  1.  
  2.  
  3.  
  4. -------listing 2---note: do not change formatting in first 3 lines-------
  5. #include <stdio.h>
  6. #define QQ      1
  7. #define TT         1
  8.  
  9. main(c,v)
  10. int c;
  11. char **v;
  12. {
  13.         char tt[12],qq[7];
  14.         int q=0,o=1,l=1,m=1;
  15.         struct {int c;} f;
  16.         qq[6]='\0';tt[11]='\0';
  17.         if(QQ==atoi(v[1])+1){
  18.                 (void)fprintf(stderr,"%s factorial = %d\n",v[1], TT);exit(1);
  19.         }
  20.         o=c+f -o ;
  21.         while(EOF!=(o=getchar())) {
  22.                 if(l && q=='Q' && o=='Q'){
  23.                         l=0;
  24.                         (void)getchar();
  25.                         (void)fread(qq,6,1,stdin);
  26.                         (void)printf("Q %6d",atoi(qq)+1);
  27.                 } else if(m && q=='T' && o=='T'){
  28.                         m=0;
  29.                         (void)fread(tt,11,1,stdin);
  30.                         (void)printf("T %9d\n",atoi(tt)*QQ);
  31.                 } else {
  32.                         q=o;
  33.                         (void)putchar(o);
  34.                 }
  35.         }
  36.         exit(0);
  37. }
  38. --------------------end of listing 2------------
  39.  
  40.